﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>EasyFMS 1.0系统登录</title>
    <link href="Content/Css/login.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="Scripts/common.js"></script>
    <script type="text/javascript">
        //回车键
        document.onkeydown = function (e) {
            if (!e) e = window.event;
            if ((e.keyCode || e.which) == 13) {
                $("#loginSubmit").click();
            }
        }

        $(function () {
            $(".txt").focus(function () {
                $(this).addClass("txt-focus");
            }).blur(function () {
                $(this).removeClass("txt-focus");
            });

            if (!navigator.cookieEnabled) {
                $("#cp").html("浏览器配置错误: Cookie不可用!请启用Cookie!").css("color", "red");
                $("#loginSubmit").hide()
            }
            else {
                $("#txtUserName").focus();
                $("#cp").html("最佳浏览环境：IE8.0～10.0或基于IE内核的浏览器，1280×800显示分辨率。").css("color", "#fff");
                $("#loginSubmit").click(function () {
                    $("#errorMsg0").empty();
                    $("#errorMsg1").empty();
                    var username = $("#txtUserName").val();
                    var password = $("#txtUserPwd").val();
                    if (Trim($.trim(username), 'g') == "") {
                        $("#txtUserName").focus();
                        $("#errorMsg0").html("用户不能为空");
                        return false;
                    }
                    if (password == "") {
                        $("#txtUserPwd").focus();
                        $("#errorMsg1").html("密码不能为空");
                        return false;
                    }
                    $.ajax({
                        type: 'post', cache: false, dataType: 'json',
                        url: 'Handler/validate.ashx',
                        data: [
                            { name: 'Action', value: 'Login' },
                            { name: 'username', value: escape(username) },
                            { name: 'password', value: password }
                        ],
                        beforeSend: function () {
                            $("#loginSubmit").attr("disabled", true)
                            $("#loginSubmit").attr("class", "signload");
                            $(".load").show();
                        },
                        success: function (result) {
                            if(result)
                                window.top.location.href = decodeURIComponent("Home.aspx")
                            else
                                $("#errorMsg0").html("用户或密码错误");
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            window.location.href = decodeURIComponent("Error.aspx")
                        },
                        complete: function () {
                            $("#loginSubmit").attr("disabled", false)
                            $("#loginSubmit").attr("class", "sign");
                            $(".load").hide();
                        }
                    });
                });
            }
        })
    </script>
</head>
<body style="padding-top: 167px">
    <form id="form1" runat="server">
        <div class="boxLogin">
            <dl>
                <dd>
                    <div class="s1">
                        登录用户：
                    </div>
                    <div class="s2">
                        <input type="text" id="txtUserName" value="" class="txt" style="width: 122px;" />
                        <span id="errorMsg0" class="errorMsg"></span>
                    </div>
                </dd>
                <dd>
                    <div class="s3">
                        登录密码：
                    </div>
                    <div class="s4">
                        <input type="password" onpaste="return false;" id="txtUserPwd" value="" class="txt" onpaste="return false;"
                            style="width: 122px;" />&nbsp;<span id="errorMsg1" class="errorMsg"></span>
                    </div>
                </dd>
                <dd>
                    <div class="load">
                        <img src="Content/Images/Login/loading.gif" />
                    </div>
                </dd>
            </dl>
            <div class="s8">
                <input id="loginSubmit" type="button" class="sign" />
            </div>
        </div>
        <div class="copyright">
            <p id="cp">
            </p>
        </div>
    </form>
</body>
</html>
